import React from 'react'

import {WeaLocaleProvider, WeaTools} from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

import './style'
import ContainerModle from '../../common/containerModle'
import AddExtend from './addExtend'
import SettingExtend from './settingExtend'
import SettingProxy from './settingProxy'
import ContainerViewExtend from './containerViewExtend'
import ContainerViewProxy from './containerViewProxy'


export default class CompanyNews extends React.Component{

    static defaultProps = {
        javaInterface:{
            find: '/api/portalTsLogin/element/getWorkflowPerfectData',
            save: '/api/portalTs/customWorkflowPerfect/save',
            update: '/api/portalTs/customWorkflowPerfect/update',
            saveOrUpdateItem: '/api/portalTs/customWorkflowPerfect/saveOrUpdateItem',
            deleteItem: '/api/portalTs/customWorkflowPerfect/deleteItem',
            orderItem: '/api/portalTs/customWorkflowPerfect/orderItem',
        }
    }

    onSaveBeforeHandler = (setting={})=>{
        setting.title = getLabel(130832, '流程中心')
        setting.remindLogo = 1
        setting.remindWeight = 0
        setting.remindOblique = 0
        setting.hasRemindColor = 0
        setting.remindColor = '#000000'
    }


    onLoadAfterHandler = (data)=>{
        // for(let i in data.showFields){
        //     if(data.showFields.hasOwnProperty(i)){
        //         data.showFields[i].name = getLabel(data.showFields[i].name, data.showFields[i].name)
        //     }
        // }


        // for(let i in data.orderFields){
        //     if(data.orderFields.hasOwnProperty(i)){
        //         data.orderFields[i].fieldName = getLabel(data.orderFields[i].fieldName, data.orderFields[i].fieldName)
        //     }
        // }
        const  {remindLogo,remindWeight,remindOblique,hasRemindColor,remindColor} = data.setting
        if(data.items.length > 0 ){
            for(let i = 0 ; i< data.items.length ; i++){
                for(let j = 0 ; j< data.items[i].data.length ;j++){
                    if(data.items[i].data[j].requestname.img !=''){
                        let css = ""
                        if(remindWeight == '1'){
                            css +="font-weight:700;"
                        }
                        if(remindOblique == '1'){
                            css +="font-style:oblique;"
                        }
                        if(hasRemindColor == "1"){
                            css +="color:"+remindColor+";"
                        }
                        data.items[i].data[j].requestname.name = "<span style='"+css+"'>"+(data.items[i].data[j].requestname.pretitle ? data.items[i].data[j].requestname.pretitle : '') + data.items[i].data[j].requestname.name + (data.items[i].data[j].requestname.lasttitle ?  data.items[i].data[j].requestname.lasttitle : '')+"</span>"
                    }else{
                        data.items[i].data[j].requestname.name = "<span>"+(data.items[i].data[j].requestname.pretitle ? data.items[i].data[j].requestname.pretitle : '') + data.items[i].data[j].requestname.name + (data.items[i].data[j].requestname.lasttitle ?  data.items[i].data[j].requestname.lasttitle : '')+"</span>"
                    }

                }
            }
        }

    }

    render(){

        return (
            <ContainerModle ecId={`${this && this.props && this.props.ecId || ''}_ContainerModle@v0eq34`} {...this.props} {...(this.props.location ? this.props.location.query :{})} ContainerViewProxy={ContainerViewProxy} SettingProxy={SettingProxy} onSaveBeforeHandler={this.onSaveBeforeHandler} onLoadAfterHandler={this.onLoadAfterHandler} AddExtend={AddExtend} SettingExtend={SettingExtend} ContainerViewExtend={ContainerViewExtend} >
            </ContainerModle>
        )
    }
}